Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numeric Input: Treat unrecognized simplify values as "required" #2308

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

benchristel
Copy link
Member

Context: I'm seeing errors in Sentry because the perseus JSON parser doesn't
understand some of the values of simplify that exist in production data. This
PR ensures we accept and handle those values.

Summary:

  • I added tests to characterize the behavior of numeric input scoring for all
    the values of simplify that are in production.
  • I updated the perseus JSON parser to convert nonstandard simplify values
    to equivalent ones.

Issue: none

Test plan:

yarn test

Copy link
Contributor

github-actions bot commented Mar 19, 2025

Size Change: +235 B (+0.03%)

Total Size: 735 kB

Filename Size Change
packages/perseus-core/dist/es/index.js 32.2 kB +235 B (+0.74%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 39.7 kB
packages/keypad-context/dist/es/index.js 760 B
packages/kmath/dist/es/index.js 11.1 kB
packages/math-input/dist/es/index.js 77.5 kB
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-editor/dist/es/index.js 136 kB
packages/perseus-linter/dist/es/index.js 22.8 kB
packages/perseus-score/dist/es/index.js 20.6 kB
packages/perseus/dist/es/index.js 369 kB
packages/perseus/dist/es/strings.js 6.73 kB
packages/pure-markdown/dist/es/index.js 4.14 kB
packages/simple-markdown/dist/es/index.js 13.1 kB

compressed-size-action

pipeParsers(boolean).then(
convert((value) => {
if (typeof value === "boolean") {
return value ? "required" : "optional";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SonicScrewdriver I changed the behavior here to match what the code was doing in production before this parser existed. It seems like the scoring logic treats both true and false as "required", so I removed the conditional that converts false into "optional". Please let me know if I'm missing something here!

Copy link
Contributor

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (4c784d8) and published it to npm. You
can install it using the tag PR2308.

Example:

pnpm add @khanacademy/perseus@PR2308

If you are working in Khan Academy's webapp, you can run:

./dev/tools/bump_perseus_version.sh -t PR2308

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant